package com.boot.controller;

import com.boot.document.WeUserCustomer;
import com.boot.entity.PageInfo;
import com.boot.service.QueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * DESC: QueryController
 *
 * @author WangJie
 * @date Created in 2025-03-31 11:04
 */
@RestController
@RequestMapping ("/code")
public class QueryController {

    @Autowired
    private QueryService queryService;

    /**
     * 添加数据到索引
     * @return indexName
     * @throws IOException
     */
    @RequestMapping("/insertDocument")
    public void insertDocument() throws Exception {
        queryService.insertDocument();
    }

    /**
     * 更新索引数据
     * @return indexName
     * @throws IOException
     */
    @RequestMapping("/updateDocument")
    public void updateDocument() throws Exception {
        queryService.updateDocument();
    }

    /**
     * 新增或更新索引数据
     * @return indexName
     * @throws IOException
     */
    @RequestMapping("/insertOrUpdateDocument")
    public void insertOrUpdateDocument() throws Exception {
        queryService.insertOrUpdateDocument();
    }

    /**
     * 删除索引数据
     * @return indexName
     * @throws IOException
     */
    @RequestMapping("/deleteDocument")
    public void deleteDocument() throws Exception {
        queryService.deleteDocument();
    }

    /**
     * 查询索引全部数据
     * @param weUserCustomer
     * @return List<WeUserCustomer>
     * @throws IOException
     */
    @RequestMapping ("/queryAll")
    public List<WeUserCustomer> queryAll(@RequestBody WeUserCustomer weUserCustomer) throws Exception {
        return queryService.queryWeCustomer(weUserCustomer);
    }

    /**
     * 分页查询索引数据
     * @param weUserCustomer
     * @return List<WeUserCustomer>
     * @throws IOException
     */
    @RequestMapping ("/queryPage")
    public PageInfo<WeUserCustomer> queryPage(@RequestBody WeUserCustomer weUserCustomer) throws Exception {
        return queryService.queryWeCustomerPage(weUserCustomer);
    }
}
